package com.ruoyi.seedlingSys.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.seedlingSys.domain.Temperaturerecord;
import com.ruoyi.seedlingSys.service.ITemperaturerecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 记录温度和湿度数据Controller
 * 
 * @author ruoyi
 * @date 2025-03-11
 */
@RestController
@RequestMapping("/seedlingSys/temperaturerecord")
public class TemperaturerecordController extends BaseController
{
    @Autowired
    private ITemperaturerecordService temperaturerecordService;

    /**
     * 查询记录温度和湿度数据列表
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:temperaturerecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(Temperaturerecord temperaturerecord)
    {
        startPage();
        List<Temperaturerecord> list = temperaturerecordService.selectTemperaturerecordList(temperaturerecord);
        return getDataTable(list);
    }

    /**
     * 导出记录温度和湿度数据列表
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:temperaturerecord:export')")
    @Log(title = "记录温度和湿度数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Temperaturerecord temperaturerecord)
    {
        List<Temperaturerecord> list = temperaturerecordService.selectTemperaturerecordList(temperaturerecord);
        ExcelUtil<Temperaturerecord> util = new ExcelUtil<Temperaturerecord>(Temperaturerecord.class);
        util.exportExcel(response, list, "记录温度和湿度数据数据");
    }

    /**
     * 获取记录温度和湿度数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:temperaturerecord:query')")
    @GetMapping(value = "/{recordID}")
    public AjaxResult getInfo(@PathVariable("recordID") Long recordID)
    {
        return success(temperaturerecordService.selectTemperaturerecordByRecordID(recordID));
    }

    /**
     * 新增记录温度和湿度数据
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:temperaturerecord:add')")
    @Log(title = "记录温度和湿度数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Temperaturerecord temperaturerecord)
    {
        return toAjax(temperaturerecordService.insertTemperaturerecord(temperaturerecord));
    }

    /**
     * 修改记录温度和湿度数据
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:temperaturerecord:edit')")
    @Log(title = "记录温度和湿度数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Temperaturerecord temperaturerecord)
    {
        return toAjax(temperaturerecordService.updateTemperaturerecord(temperaturerecord));
    }

    /**
     * 删除记录温度和湿度数据
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:temperaturerecord:remove')")
    @Log(title = "记录温度和湿度数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIDs}")
    public AjaxResult remove(@PathVariable Long[] recordIDs)
    {
        return toAjax(temperaturerecordService.deleteTemperaturerecordByRecordIDs(recordIDs));
    }
}
